home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / powerb5.zip / LENGTH.BAT < prev    next >
DOS Batch File  |  1993-06-01  |  834b  |  35 lines

  1. @ECHO OFF
  2. REM Make sure the STRING isn't empty
  3. IF "%STRING%"=="" GOTO error
  4.  
  5. REM Add a sentinel at the end. The "block" character, ASCII
  6. REM 254, can be obtained by typing "254" while holding down
  7. REM the <Alt> key on your keyboard.
  8. SET TEMPSTR=%STRING%■
  9.  
  10. REM Length is at least 1
  11. SET LNGTH=1
  12.  
  13. REM DOS's batch language can't do math, so
  14. REM increment counter using simple comparisons
  15.  
  16. :loop
  17. REM Chop off the first character of the STRING
  18. FOR %%Y IN (/%TEMPSTR%) DO SET TEMPSTR=%%Y
  19. IF "%TEMPSTR%"=="■" GOTO done
  20.  
  21. IF  %LNGTH%==8  GOTO  error
  22. IF  %LNGTH%==7  SET   LNGTH=8
  23. IF  %LNGTH%==6  SET   LNGTH=7
  24. IF  %LNGTH%==5  SET   LNGTH=6
  25. IF  %LNGTH%==4  SET   LNGTH=5
  26. IF  %LNGTH%==3  SET   LNGTH=4
  27. IF  %LNGTH%==2  SET   LNGTH=3
  28. IF  %LNGTH%==1  SET   LNGTH=2
  29.  
  30. GOTO loop
  31. :error
  32. SET LNGTH=?
  33. :done
  34. SET TEMPSTR=
  35.